package com.yiyuzi.wiki.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author yiyuzi
 * @date 2021/5/8 17:10
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 直接new一个拦截器，在拦截器调用其他注入类会报空指针异常，通过注入添加拦截器不会报
     */
    @Resource
    private WikiInterceptorAdapter adminInterceptorAdapter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptorAdapter);
    }
}
